//
// Created by xili on 2024/8/5 20:54.
// Go big or go home.
//
#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    string sortSentence(string s) {
        unordered_map<int, string> ump;
        int n = s.size();
        int i = 0;
        while (i < n) {
            string word;
            while (i < n && !isdigit(s[i])) {
                word += s[i];
                i++;
            }
            int pos = s[i] - '0';
            ump[pos] = word;
            i++; // 跳过数字
            i++; // 跳过空格
        }
        string ans;
        for (int i = 1; i <= ump.size(); i++) {
            ans += ump[i] + " ";
        }
        ans.pop_back(); // 移除末尾多余的空格
        return ans;
    }
};
